package com.dems.admin.controller;

import com.dems.domain.DeviceSignalDataDto;
import com.dems.domain.DeviceSignalReqVO;
import com.dems.domain.JsonResponse;
import com.dems.service.DeviceSignalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/deviceSignal")
public class DeviceSignalController {

    @Autowired
    private DeviceSignalService deviceSignalService;

    @PostMapping("/findByRoomId")
    public JsonResponse findByRoomId(@RequestBody DeviceSignalReqVO deviceSignalReqVO){
        return JsonResponse.success(deviceSignalService.selectByRoomId(deviceSignalReqVO));
    }

    @PostMapping("/findByDeviceId")
    public JsonResponse findByDeviceId(@RequestBody DeviceSignalReqVO deviceSignalReqVO){
        return JsonResponse.success(deviceSignalService.selectByDeviceId(deviceSignalReqVO));
    }

    @PostMapping("/dataList")
    public JsonResponse findMonitorValueByRoomId(@RequestBody DeviceSignalDataDto deviceSignalDataDto){
        return JsonResponse.success(deviceSignalService.selectSignalData(deviceSignalDataDto));
    }

    @PostMapping("/delete")
    public JsonResponse deleteDeviceSignal(@RequestBody DeviceSignalDataDto deviceSignalDataDto){
        return JsonResponse.success(deviceSignalService.deleteDevSignal(deviceSignalDataDto));
    }
}
